﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FMALog
{
    public class Log
    {
        private Exception _error;
        public Log()
        {
            exception = null;
            dateTime = DateTime.Now;
            type = LogType.Info;
            message = String.Empty;
        }
        public String message { get; set; }
        public Exception exception
        {
            get { return this._error; }
            set
            {
                if (value != null)
                {
                    this._error = value; message = value.Message;
                }
                type = LogType.Error;
            }
        }
        public LogType type { get; set; }
        public DateTime dateTime { get; set; }
        public String ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(dateTime.ToShortDateString() + "-");
            sb.Append(dateTime.ToShortTimeString() + " => ");
            sb.Append(type.ToString() + " => ");
            sb.Append(message);
            if (exception != null)
                sb.AppendLine(exception.StackTrace);
            return sb.ToString();
        }
    }
}
